#!/usr/bin/perl -w
use strict;
use CGI;
use DBI;


our $serverip;
our $serverport;
our $rrdfilepath; 
our $rrdimgpath;
our $htmlfilepath;
our $mumonitorpath;
our $mumonitorcmdpath;
our $rrdtoolcmd;
our $db_hostname;
our $db_port;
our $db_name;
our $dsn;
our $username;
our $password;
our $SMTP_SERVER;
our $SENDER; 
our $bandwidth_in_mib;
our $bandwidth_out_mib;
our $bandwidth_2_in_mib;
our $bandwidth_2_out_mib;
our $total_swap_mib;
our $avail_swap_mib;
our $total_ram_mib;
our $avail_ram_mib;
our $load_1min_mib;
our $load_5min_mib;
our $load_15min_mib;
our $cpu_user_mib;
our $cpu_system_mib;
our $tcp_connection_mib;
our $update_mib;
our @rrd_name1;
our @rrd_name2;
our @application_list;

if ( -f "/www/mumonitor/monitor/mumonitor.conf") {
        require "/www/mumonitor/monitor/mumonitor.conf";
} else {
  	dir("Mumonitor need configuration file not found! .\n");
}

my $monitor_network_bandwidth = 0;
my $monitor_system = 0;
my $Application_icmp = 0;
my $Application_http = 0;

my %query = parse_form_data (); 
my ($key,$value,$ServerName,$Ipaddr,$SnmpCommunity,$monitor_http_url,$Description,$Mailbox);

chomp(my $starttimestamp = `/bin/date -d yesterday +%s`);

while ( ($key, $value) = each %query ) {
    if ($key eq 'ipaddr') {
	    my $Ipaddr_htmlcheck = iPAddressCheck ($value);
		if ( $Ipaddr_htmlcheck == 0 ) {
			print "Location: /input.htm\n\n"
		}
	}
	if ($key eq 'server_name') {
		my $servername_check = ( $value =~ /^[a-zA-Z][a-zA-Z0-9_]*/ );
		if ( $servername_check == 0 ) {
			print "Location: /input.htm\n\n"
		}
	}
}

while ( ($key, $value) = each %query ) {
	if ($key eq 'monitor_server') {
		if ( $value eq 'yes' ) {
			$monitor_system = 1;
		}
	}
	if ($key eq 'monitor_nb') {
		if ( $value eq 'yes' ) {
            $monitor_network_bandwidth = 1;
		}
	}
    if ($key eq 'server_name') {
        $ServerName = $value;
    }   
    if ($key eq 'ipaddr') {
		$Ipaddr = $value;
	}
    if ($key eq 'snmpcommunity') {
		$SnmpCommunity = $value;
	}
	if ($key eq 'monitor_http_url') {
		$monitor_http_url = $value;
	}
    if ($key eq 'server_description') {
		$Description = $value;
	}
	if ($key eq 'mailbox') {
		$Mailbox = $value;
	}
	if ($key eq 'App_icmp') {
		$Application_icmp = 1;
	}
	if ($key eq 'App_http') {
		$Application_http = 1;
	}
	
}

&dbitomysql($ServerName,$Ipaddr,$SnmpCommunity,$monitor_system,$monitor_network_bandwidth,$Description,$Mailbox,$Application_icmp,$Application_http,$monitor_http_url);

if (($monitor_system == 1) || ($monitor_network_bandwidth == 1 )) {
	&createrrddir($rrdimgpath,$Ipaddr);
	&createrrddir($rrdfilepath,$Ipaddr);
	&createrrddir($htmlfilepath,$Ipaddr);
}

if (($monitor_system == 1) && ($monitor_network_bandwidth == 1 )) {
	my $tmpid = 0;
	&createhtml($ServerName,$Ipaddr,$tmpid);
}elsif ($monitor_system == 1) {
	my $tmpid = 1;
	&createhtml($ServerName,$Ipaddr,$tmpid);
}elsif ($monitor_network_bandwidth == 1) {
	my $tmpid = 2;
	&createhtml($ServerName,$Ipaddr,$tmpid);
}

if ($monitor_network_bandwidth == 1) {
	my $tmprrd = 0;
	&createrrd($Ipaddr,$tmprrd,@rrd_name1);
}
if ($monitor_system == 1) {
 	my $tmprrd = 1;
	&createrrd($Ipaddr,$tmprrd,@rrd_name2);
}

&createmumonitor($ServerName,$Ipaddr);

print "Location: /monitor.htm\n\n";

sub parse_form_data {
	my %form_data;
	my $name_value;
	my @name_value_pairs = split /&/, $ENV{QUERY_STRING};
	foreach $name_value ( @name_value_pairs ) {
		my( $name, $value ) = split /=/, $name_value;

		$name =~ tr/+/ /;
		$name =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi;
		
		$value = "" unless defined $value;
		$value =~ tr/+/ /;
		$value =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi;

		$form_data{$name} = $value;
	}
	return %form_data;
}

sub iPAddressCheck {
	my $intFlag = 0;                   #Set to 1 when matched
	my ($strIP) = @_;
	$strIP =~s/^\s*//;                 #Delete front blanks
	$strIP =~s/\s*$//;                 #Delete end blanks
	if($strIP =~ /^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/)
	{
		if($1 !~/^0\d+$/ && $2 !~/^0\d+$/ && $3 !~/^0\d+$/ && $4 !~/^0\d+$/)
		{
			if($1<224 && $1!= 127 && $2<255 && $3<255 && $4<255 && $4!=0)
			{
				$intFlag = 1;
			}
		}
	}
	return $intFlag;
}

sub dbitomysql {
	my $dbh = DBI->connect($dsn,$username,$password);
	my $curruser = 0;
	my $uptime = "0";
	my $icmp = $_[7];
	my $http = $_[8];
	$dbh->do("INSERT INTO mu_server VALUES ('$_[0]', '$_[1]', '$_[2]', '$_[3]', '$_[4]', '$_[5]','$_[6]','$curruser','$uptime')");
	if (($icmp== 1) && ($http == 1)){
		$dbh->do("INSERT INTO mu_monitor_server VALUES ('$_[1]','11','$_[9]','','','$uptime')");
	}elsif (($icmp == 1) && ($http == 0)){
		$dbh->do("INSERT INTO mu_monitor_server VALUES ('$_[1]','10','','','','$uptime')");
	}elsif (($icmp == 0) && ($http == 1)){
		$dbh->do("INSERT INTO mu_monitor_server VALUES ('$_[1]','01','$_[9]','','','$uptime')");
	}
	$dbh->disconnect();
}

sub createrrddir {
	my $rrdprepath = $_[0];
	my $rrdpath = $_[1];
	mkdir "$rrdprepath$rrdpath", 0755 or die "cannot create $rrdprepath$rrdpath: $!";
}

sub createrrd {
	my $rrdname1=shift(@_);
	my $tmprrd=shift(@_);
	my @rrdname2=@_;
	my $rrdname_rank="";
	chdir "$rrdfilepath$rrdname1" or die "cannot chdir to $rrdfilepath$rrdname1: $!";
	if ($tmprrd == 0) {
		foreach $rrdname_rank ( @rrdname2 ) {
			system("$rrdtoolcmd create $rrdname_rank -b $starttimestamp -s 300 DS:traffic_in:COUNTER:600:0:10000000 DS:traffic_out:COUNTER:600:0:10000000 RRA:AVERAGE:0.5:1:51840 RRA:AVERAGE:0.5:24:2160 RRA:AVERAGE:0.5:6:8736 RRA:AVERAGE:0.5:288:797 RRA:MIN:0.5:1:51840 RRA:MIN:0.5:24:2160 RRA:MIN:0.5:6:8736 RRA:MIN:0.5:288:797 RRA:MAX:0.5:1:51840 RRA:MAX:0.5:24:2160 RRA:MAX:0.5:6:8736 RRA:MAX:0.5:288:797 RRA:LAST:0.5:1:51840 RRA:LAST:0.5:24:2160 RRA:LAST:0.5:6:8736 RRA:LAST:0.5:288:797"); 
		}
	}
	else {
		foreach $rrdname_rank ( @rrdname2 ) {
			system("$rrdtoolcmd create $rrdname_rank -b $starttimestamp -s 300 DS:$rrdname_rank:GAUGE:600:U:U RRA:AVERAGE:0.5:1:603 RRA:AVERAGE:0.5:6:603 RRA:AVERAGE:0.5:24:603 RRA:AVERAGE:0.5:288:800 RRA:MAX:0.5:1:603 RRA:MAX:0.5:6:603 RRA:MAX:0.5:24:603 RRA:MAX:0.5:288:800");
		}
	}
}

sub createmumonitor {
	my $ServerName_mu = $_[0];
	my $Ipaddr_mu = $_[1];
	my $newfile="tmp.file";
	my $oldfile="monitor.htm";
	open OLD, "<$mumonitorpath$oldfile" or die "can't open $mumonitorpath$oldfile: $!";
	open NEW, ">$mumonitorpath$newfile" or die "can't open $mumonitorpath$newfile: $!";
	chdir "$mumonitorpath" or die "cannot chdir to $mumonitorpath: $!";
	while (<OLD>) {
		if ( $_ =~ /\<\/table\>/) {
			select NEW;
			print "<!--$Ipaddr_mu-->\n";
			print "<tr>\n";
            print "<td>\n";
            print "<div align=\"left\">$ServerName_mu</div>\n";
            print "</td>\n";
            print "<td>\n";
            print "<div align=\"left\">$Ipaddr_mu</div>\n";
            print "</td>\n";
            print "<td>\n";
            print "<div align=\"left\"><a href=\"/html/$Ipaddr_mu/\">rrdtools</a></div>\n";
            print "</td>\n";
			print "<td>\n";
			print "<!--Current Login User $Ipaddr_mu--><div align=\"left\">detecting</div>\n";
            print "</td>\n";
			print "<td>\n";
			print "<!--SSH Lastest Logs $Ipaddr_mu--><div align=\"left\"><a href=\"/html/$Ipaddr_mu/ssh\.html\">detecting</a></div>\n";
            print "</td>\n";
			print "<td>\n";
			print "<!--Server Started Time $Ipaddr_mu--><div align=\"left\">detecting</div>\n";
            print "</td>\n";
			print "<td>\n";
			print "<!--ICMP monitor $Ipaddr_mu--><div align=\"left\"><a href=\"/html/$Ipaddr_mu/ping\.html\">-</a></div>\n";
			print "</td>\n";
			print "<td>\n";
			print "<!--HTTP monitor $Ipaddr_mu--><div align=\"left\"><a href=\"/html/$Ipaddr_mu/http\.html\">-</a></div>\n";
			print "</td>\n";
            print "<td>\n";
            print "<div align=\"center\">\n";
            print "<input type=\"checkbox\" name=\"checkbox_$Ipaddr_mu\" value=\"$Ipaddr_mu\">\n";
            print "</div>\n";
            print "</td>\n";
            print "</tr>\n";
            print NEW $_;
            select STDOUT;
        } else {
			print NEW $_;
		}
	}
	close(OLD) or die "can't close $oldfile: $!";
	close(NEW) or die "can't close $newfile: $!";
	rename($newfile, $oldfile) or die "can't rename $newfile to $oldfile: $!";
}

sub createhtml {
	my $ServerName_html = $_[0];
	my $Ipaddr_html = $_[1];
	my $tmpid_html = $_[2];
	chdir "$htmlfilepath$Ipaddr_html" or die "cannot chdir to $htmlfilepath$Ipaddr_html: $!";
	if ($tmpid_html == 0) {
		open HTMLFILE, ">index.html" or die "Cannot create index.html: $!";
		select HTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
			print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
			print "<body>\n";
			print "<h1 align=center>$ServerName($Ipaddr_html)</h1>\n";
			print "<hr>\n";
			print "<br>\n";
			print "<center>\n";
			print "<a href=\"eth.html\"><img src=\"/img/$Ipaddr_html/eth_day.png\" border=\"0\"></a>\n";
			print "<br>\n";
			print "<a href=\"load.html\"><img src=\"/img/$Ipaddr_html/load_day.png\" border=\"0\"></a>\n";
			print "<br>\n";
			print "<a href=\"cpu.html\"><img src=\"/img/$Ipaddr_html/cpu_day.png\" border=\"0\"></a>\n";
			print "<br>\n";
			print "<a href=\"mem.html\"><img src=\"/img/$Ipaddr_html/mem_day.png\" border=\"0\"></a>\n";
			print "<br>\n";
			print "<a href=\"tcp.html\"><img src=\"/img/$Ipaddr_html/tcp_day.png\" border=\"0\"></a>\n";
			print "</center>\n";
			print "</body>\n";
			print "</html>\n";
		close HTMLFILE;
		open ETHHTMLFILE, ">eth.html" or die "Cannot create eth.html: $!";
		select ETHHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName($Ipaddr_html)--In and Out Bandwidth</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close ETHHTMLFILE;
		open LOADHTMLFILE, ">load.html" or die "Cannot create load.html: $!";
		select LOADHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--Load Average Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close LOADHTMLFILE;
		open CPUHTMLFILE, ">cpu.html" or die "Cannot create cpu.html: $!";
		select CPUHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--CPU Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close CPUHTMLFILE;
		open MEMHTMLFILE, ">mem.html" or die "Cannot create mem.html: $!";
		select MEMHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--MEM Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close MEMHTMLFILE;
		open TCPHTMLFILE, ">tcp.html" or die "Cannot create tcp.html: $!";
		select TCPHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--Tcp Connection</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close TCPHTMLFILE;
		select STDOUT;
	} elsif ($tmpid_html == 1) {
		open HTMLFILE, ">index.html" or die "Cannot create index.html: $!";
        select HTMLFILE;
	        print "<HTML>\n";
	        print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
	        print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)</h1>\n";
	        print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<a href=\"load.html\"><img src=\"/img/$Ipaddr_html/load_day.png\" border=\"0\"></a>\n";
	        print "<br>\n";
	        print "<a href=\"cpu.html\"><img src=\"/img/$Ipaddr_html/cpu_day.png\" border=\"0\"></a>\n";
	        print "<br>\n";
	        print "<a href=\"mem.html\"><img src=\"/img/$Ipaddr_html/mem_day.png\" border=\"0\"></a>\n";
	        print "<br>\n";
	        print "<a href=\"tcp.html\"><img src=\"/img/$Ipaddr_html/tcp_day.png\" border=\"0\"></a>\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
        close HTMLFILE;
		open LOADHTMLFILE, ">load.html" or die "Cannot create load.html: $!";
		select LOADHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--Load Average Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/load_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close LOADHTMLFILE;
		open CPUHTMLFILE, ">cpu.html" or die "Cannot create cpu.html: $!";
		select CPUHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--CPU Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/cpu_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close CPUHTMLFILE;
		open MEMHTMLFILE, ">mem.html" or die "Cannot create mem.html: $!";
		select MEMHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--MEM Status</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/mem_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close MEMHTMLFILE;
		open TCPHTMLFILE, ">tcp.html" or die "Cannot create tcp.html: $!";
		select TCPHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)--Tcp Connection</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/tcp_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close TCPHTMLFILE;
		select STDOUT;
	} elsif ($tmpid_html == 2) {
		open HTMLFILE, ">index.html" or die "Cannot create index.html: $!";
        select HTMLFILE;
	        print "<HTML>\n";
	        print "<head>\n";
	        print "<title>$ServerName rrd monitor</title>\n";
	        print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)</h1>\n";
	        print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<a href=\"eth.html\"><img src=\"/img/$Ipaddr_html/eth_day.png\" border=\"0\"></a>\n";
	        print "<br>\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
        close HTMLFILE;
		open ETHHTMLFILE, ">eth.html" or die "Cannot create eth.html: $!";
		select ETHHTMLFILE;
			print "<HTML>\n";
			print "<head>\n";
	        print "<title>$ServerName($Ipaddr_html)--In and Out Bandwidth</title>\n";
			print "</head>\n";
	        print "<body>\n";
	        print "<h1 align=center>$ServerName($Ipaddr_html)</h1>\n";
			print "<hr>\n";
	        print "<br>\n";
	        print "<center>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_day.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_weekly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_monthly.png\">\n";
	        print "<br>\n";
	        print "<img src=\"/img/$Ipaddr_html/eth_yearly.png\">\n";
	        print "</center>\n";
	        print "</body>\n";
	        print "</html>\n";
		close ETHHTMLFILE;
		select STDOUT;
	}
}
